import 'package:flutter/material.dart';
import '../../../widget/PPBaseWidget.dart';

class PPCommodityDetailPage extends StatefulWidget with PPBaseWidget {

    PPCommodityDetailPage({Key key}): super(key: key);

    _PPCommodityDetailPageState createState() => _PPCommodityDetailPageState();

}

class _PPCommodityDetailPageState extends State<PPCommodityDetailPage> {

    String commodityId;

    @override
    void initState() {
        
        super.initState();
    }

    @override
    void didUpdateWidget(PPCommodityDetailPage oldWidget) {
        
        super.didUpdateWidget(oldWidget);
    }

    @override
    Widget build(BuildContext context) {
        
        return Scaffold(
            body: NestedScrollView(
                headerSliverBuilder: _sliverBuilder,
                body: Center(
                    child: ListView.builder(
                    itemBuilder: _itemBuilder,
                    itemCount: 15,
                    ),
                )
            ),
        );
    }

    List<Widget> _sliverBuilder(BuildContext context, bool innerBoxIsScrolled) {
        return <Widget>[
            SliverAppBar(
                centerTitle: true,    //标题居中
                title: Text('我是一个FlexibleSpaceBar'),
                expandedHeight: 200.0,  //展开高度200
                floating: true,  //不随着滑动隐藏标题
                pinned: true,    //固定在顶部
                flexibleSpace: FlexibleSpaceBar(
                    centerTitle: true,
                    
                    background: Image.network("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531798262708&di=53d278a8427f482c5b836fa0e057f4ea&imgtype=0&src=http%3A%2F%2Fh.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F342ac65c103853434cc02dda9f13b07eca80883a.jpg", fit: BoxFit.cover),
                ),
                actions: [
                    Icon(Icons.add),
                    Icon(Icons.share),
                    Icon(Icons.search)
                ]
            )
        ];
    }

    Widget _itemBuilder(BuildContext context, int index) {
        return ListTile(
            leading: Icon(Icons.android),
            title: Text('无与伦比的标题+$index'),
        );
    }


}